def calculator():
    print("=== 简单计算器 ===")
    print("支持的运算符: +, -, *, /")
    print()
    
    try:
        num1 = float(input("请输入第一个数: "))
        operator = input("请输入运算符: ")
        num2 = float(input("请输入第二个数: "))
    except ValueError:
        print("输入错误，请输入有效的数字！")
        return
    except KeyboardInterrupt:
        print("\n程序已退出")
        return

    if operator == "+":
        result = num1 + num2
    elif operator == "-":
        result = num1 - num2
    elif operator == "*":
        result = num1 * num2
    elif operator == "/":
        if num2 == 0:
            print("除数不能为0")
            return
        result = num1 / num2
    else:
        print("无效的运算符")
        return
    print(f"{num1} {operator} {num2} = {result}")

calculator()